﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MeetingroomUserControl.ascx.cs" Inherits="UCWebpart.Admin.MeetingroomUserControl" %>

 <link rel="stylesheet" type="text/css" href="../css/theme.css" />
    <link rel="stylesheet" type="text/css" href="../css/style1.css" />

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="mtrId" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="808px" OnRowDataBound="GridView1_RowDataBound" CellPadding="4" ForeColor="#333333" GridLines="None" OnDataBound="GridView1_DataBound">
    <AlternatingRowStyle BackColor="White" />
    <Columns>
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True">
        <ControlStyle Width="40px" />
        </asp:CommandField>
        <asp:BoundField DataField="mtrId" HeaderText="编号" InsertVisible="False" ReadOnly="True" SortExpression="mtrId" Visible="False">
        <HeaderStyle Font-Size="Small" Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="mtrName" HeaderText="名称" SortExpression="mtrName">
        <HeaderStyle Wrap="False" />
        </asp:BoundField>
        <asp:TemplateField HeaderText="公司" SortExpression="mtrCompanyRuc">
            <EditItemTemplate>
                <asp:DropDownList ID="CompanyList" runat="server" 
                     AutoPostBack="True" 
                    OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                </asp:DropDownList>

              
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("mtrCompanyRuc") %>' Visible="False"></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("mtrCompanyRuc") %>'></asp:Label>
            </ItemTemplate>
            <HeaderStyle Wrap="False" />
            <ItemStyle Wrap="False" />
        </asp:TemplateField>
        <asp:TemplateField HeaderText="可用部门" SortExpression="mtrDeptRuc">
            <EditItemTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server" 
                    OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1" AutoPostBack="True" >
                </asp:DropDownList>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("mtrDeptRuc") %>' Visible="False"></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("mtrDeptRuc") %>'></asp:Label>
            </ItemTemplate>
            <ItemStyle Wrap="False" />
        </asp:TemplateField>
        <asp:TemplateField HeaderText="场地类型" SortExpression="type">
            <EditItemTemplate>
                <asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:TextBox ID="TextBox5" runat="server"  Text='<%# Bind("type") %>' Visible="False"></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label5" runat="server" Text='<%# Bind("type") %>'></asp:Label>
            </ItemTemplate>
            <ItemStyle Wrap="False" />
        </asp:TemplateField>
        <asp:TemplateField HeaderText="位置" SortExpression="mtrAddress">
            <EditItemTemplate>
                <asp:DropDownList ID="DropDownList2" runat="server" SelectedValue ='<%# Bind("mtrAddress") %>' AutoPostBack="True" DataSourceID="SqlDataSource4" DataTextField="addressName" DataValueField="addressName" >
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:meetingroomManagementConnectionString %>" 
                    DeleteCommand="DELETE FROM [MTR_bas_AddressName] WHERE [id] = @id" 
                    InsertCommand="INSERT INTO [MTR_bas_AddressName] ([addressName], [available]) VALUES (@addressName, @available)" 
                    SelectCommand="SELECT id, addressName, available FROM MTR_bas_AddressName WHERE (available = 'true')" 
                    UpdateCommand="UPDATE [MTR_bas_AddressName] SET [addressName] = @addressName, [available] = @available WHERE [id] = @id">
                    <DeleteParameters>
                        <asp:Parameter Name="id" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="addressName" Type="String" />
                        <asp:Parameter Name="available" Type="Boolean" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="addressName" Type="String" />
                        <asp:Parameter Name="available" Type="Boolean" />
                        <asp:Parameter Name="id" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label3" runat="server" Text='<%# Bind("mtrAddress") %>'></asp:Label>
            </ItemTemplate>
            <HeaderStyle Wrap="False" />
        </asp:TemplateField>
        <asp:BoundField DataField="mtrAddress1" HeaderText="地址" SortExpression="mtrAddress1">
        <HeaderStyle Wrap="False" />
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        <asp:TemplateField HeaderText="容量" SortExpression="mtrCapacity">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox6" runat="server" onkeyup="if(isNaN(value))execCommand('undo')" Text='<%# Bind("mtrCapacity") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label8" runat="server" Text='<%# Bind("mtrCapacity") %>'></asp:Label>
            </ItemTemplate>
            <HeaderStyle Wrap="False" />
        </asp:TemplateField>
        <asp:BoundField DataField="mtrPhone" HeaderText="电话" SortExpression="mtrPhone">
        <HeaderStyle Wrap="False" />
        </asp:BoundField>
        <asp:TemplateField HeaderText="类型" SortExpression="mtrType">
            <EditItemTemplate>
                <asp:DropDownList ID="DropDownList3" runat="server" SelectedValue='<%# Bind("mtrType") %>'>
                    <asp:ListItem>普通</asp:ListItem>
                    <asp:ListItem>VIP</asp:ListItem>
                </asp:DropDownList>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label4" runat="server" Text='<%# Bind("mtrType") %>'></asp:Label>
            </ItemTemplate>
            <HeaderStyle Wrap="False" />
        </asp:TemplateField>
        <asp:BoundField DataField="mtrFreeTime" HeaderText="闲时" SortExpression="mtrFreeTime" Visible="False">
        <HeaderStyle Wrap="False" />
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="mtrPhoto" HeaderText="照片" SortExpression="mtrPhoto" Visible="False">
        <HeaderStyle Wrap="False" />
        </asp:BoundField>
        <asp:CheckBoxField DataField="mtrState" HeaderText="未冻结" SortExpression="mtrState">
        <HeaderStyle Wrap="False" />
        </asp:CheckBoxField>
        <asp:TemplateField HeaderText="最长预定时间(h)" SortExpression="mtrLongestBookingDay">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox3" runat="server" onkeyup="if(isNaN(value))execCommand('undo')"  Text='<%# Bind("mtrLongestBookingDay") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label6" runat="server" Text='<%# Bind("mtrLongestBookingDay") %>'></asp:Label>
            </ItemTemplate>
            <HeaderStyle Font-Size="Small" HorizontalAlign="Center" Wrap="False" />
        </asp:TemplateField>
        <asp:TemplateField HeaderText="最长提前天数" SortExpression="mtrLongestAdvanceBookingTime">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox4" onkeyup="if(isNaN(value))execCommand('undo')" runat="server" Text='<%# Bind("mtrLongestAdvanceBookingTime") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label7" runat="server" Text='<%# Bind("mtrLongestAdvanceBookingTime") %>'></asp:Label>
            </ItemTemplate>
            <HeaderStyle Font-Size="Small" Wrap="False" />
        </asp:TemplateField>
        <asp:BoundField DataField="mtrLastUser" HeaderText="上次使用者" SortExpression="mtrLastUser" Visible="False">
        <HeaderStyle Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="mtrLastTime" HeaderText="上次使用时间" SortExpression="mtrLastTime" Visible="False" />
        <asp:CheckBoxField DataField="mtrDelete" HeaderText="可用" SortExpression="mtrDelete" Visible="False" />
        <asp:TemplateField HeaderText="管理员" SortExpression="undefine3">
            <EditItemTemplate>
                <asp:TextBox ID="TBadmin" runat="server" Text='<%# Bind("undefine3") %>' Visible="False"></asp:TextBox>
                <asp:DropDownList ID="DDLadmin" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDLadmin_SelectedIndexChanged">
                </asp:DropDownList>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label9" runat="server" Text='<%# Bind("undefine3") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <EditRowStyle BackColor="#2461BF" />
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#EFF3FB" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <SortedAscendingCellStyle BackColor="#F5F7FB" />
    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
    <SortedDescendingCellStyle BackColor="#E9EBEF" />
    <SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:meetingroomManagementConnectionString %>" 
    DeleteCommand="update MTR_bas_Meetingroom set mtrDelete = 0 WHERE [mtrId] = @mtrId" 
    InsertCommand="INSERT INTO [MTR_bas_Meetingroom] ([mtrName],[type], [mtrCompanyRuc], [mtrDeptRuc], [mtrAddress], [mtrAddress1], [mtrCapacity], [mtrPhone], [mtrType], [mtrFreeTime], [mtrPhoto], [mtrState], [mtrLongestBookingDay], [mtrLongestAdvanceBookingTime], [mtrLastUser], [mtrLastTime], [mtrDelete], [undefine3]) VALUES (@mtrName,@type, @mtrCompanyRuc, @mtrDeptRuc, @mtrAddress, @mtrAddress1, @mtrCapacity, @mtrPhone, @mtrType, @mtrFreeTime, @mtrPhoto, @mtrState, @mtrLongestBookingDay, @mtrLongestAdvanceBookingTime, @mtrLastUser, @mtrLastTime, @mtrDelete, @undefine3)" OnSelecting="SqlDataSource1_Selecting" 
    SelectCommand="SELECT MTR_bas_Meetingroom.* FROM MTR_bas_Meetingroom (nolock) where mtrDelete=1 and 
        3 in (select distinct adminLevel from MTR_bas_Admin(nolock) where adminName=@adminName and Available=1)
        union
        select MTR_bas_Meetingroom.* from MTR_bas_Admin with(nolock) join MTR_bas_Meetingroom with(nolock) 
        on MTR_bas_Admin.[VenueType]=MTR_bas_Meetingroom.[type]
        where adminName=@adminName and MTR_bas_Admin.Available='1' and MTR_bas_Meetingroom.mtrDelete='1' order by mtrId desc" 
    UpdateCommand="UPDATE [MTR_bas_Meetingroom] SET [mtrName] = @mtrName,type= @type, [mtrCompanyRuc] = @mtrCompanyRuc, 
    [mtrDeptRuc] = @mtrDeptRuc, [mtrAddress] = @mtrAddress, [mtrAddress1] = @mtrAddress1, [mtrCapacity] = @mtrCapacity, [mtrPhone] = @mtrPhone, [mtrType] = @mtrType, [mtrFreeTime] = @mtrFreeTime, [mtrPhoto] = @mtrPhoto, [mtrState] = @mtrState, [mtrLongestBookingDay] = @mtrLongestBookingDay, [mtrLongestAdvanceBookingTime] = @mtrLongestAdvanceBookingTime, [mtrLastUser] = @mtrLastUser, [mtrLastTime] = @mtrLastTime, [mtrDelete] = 1,[undefine3] = @undefine3 WHERE [mtrId] = @mtrId">
    <DeleteParameters>
        <asp:Parameter Name="mtrId" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="mtrName" Type="String" />
        <asp:Parameter Name="type" Type="String" />
        <asp:Parameter Name="mtrCompanyRuc" Type="String" />
        <asp:Parameter Name="mtrDeptRuc" Type="String" />
        <asp:Parameter Name="mtrAddress" Type="String" />
        <asp:Parameter Name="mtrAddress1" Type="String" />
        <asp:Parameter Name="mtrCapacity" Type="Int32" />
        <asp:Parameter Name="mtrPhone" Type="String" />
        <asp:Parameter Name="mtrType" Type="String" />
        <asp:Parameter Name="mtrFreeTime" Type="String" />
        <asp:Parameter Name="mtrPhoto" Type="String" />
        <asp:Parameter Name="mtrState" Type="Boolean" />
        <asp:Parameter Name="mtrLongestBookingDay" Type="Int32" />
        <asp:Parameter Name="mtrLongestAdvanceBookingTime" Type="String" />
        <asp:Parameter Name="mtrLastUser" Type="String" />
        <asp:Parameter Name="mtrLastTime" Type="String" />
        <asp:Parameter Name="mtrDelete" Type="Boolean" />
        
        <asp:Parameter Name="undefine3" Type="String" />
    </InsertParameters>
    <SelectParameters>
        <asp:SessionParameter Name="adminName" SessionField="userName" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="mtrName" Type="String" />
        <asp:Parameter Name="type" Type ="String"/>
        <asp:Parameter Name="mtrCompanyRuc" Type="String" />
        <asp:Parameter Name="mtrDeptRuc" Type="String" />
        <asp:Parameter Name="mtrAddress" Type="String" />
        <asp:Parameter Name="mtrAddress1" Type="String" />
        <asp:Parameter Name="mtrCapacity" Type="Int32" />
        <asp:Parameter Name="mtrPhone" Type="String" />
        <asp:Parameter Name="mtrType" Type="String" />
        <asp:Parameter Name="mtrFreeTime" Type="String" />
        <asp:Parameter Name="mtrPhoto" Type="String" />
        <asp:Parameter Name="mtrState" Type="Boolean" />
        <asp:Parameter Name="mtrLongestBookingDay" Type="Int32" />
        <asp:Parameter Name="mtrLongestAdvanceBookingTime" Type="String" />
        <asp:Parameter Name="mtrLastUser" Type="String" />
        <asp:Parameter Name="mtrLastTime" Type="String" />
       
        <asp:Parameter Name="undefine3" Type="String" />
        <asp:Parameter Name="mtrId" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>
<p>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:WorkFlowConnectionString %>" 
        SelectCommand="select '所有部门' as ABBR,'0' as ID
union all 
select ABBR,ID  from [WorkFlow].[dbo].[RUC_Organization](nolock) where IfDelete=0 and OrgTypeID=3 "></asp:SqlDataSource>
</p>


<div id="Div1" runat ="server">
    <asp:Label ID="Label10" runat="server" Text="Label" Visible="False"></asp:Label>
    <fieldset id="personal">
                        <legend>Add Venue</legend>
                        <label for="mtrName">场地名称： </label> 
                        <asp:TextBox ID="mtrName" runat="server" tabindex="1"></asp:TextBox>
                        <br />
         <label for="types">场地类型： </label>
         <asp:DropDownList ID="types" runat="server" Height="25px" Width="102px" AutoPostBack="True" OnSelectedIndexChanged="types_SelectedIndexChanged">
         </asp:DropDownList>
                          <table><tr><td>
                        <label for="mtrCompanyRuc">可用部门 : </label></td><td>
                          <asp:DropDownList ID="mtrCompanyRuc" runat="server" AutoPostBack="True" 
                              OnSelectedIndexChanged="mtrCompanyRuc_SelectedIndexChanged">
                            </asp:DropDownList>
                            </td>
                              <td>
                          <div id="left1" style="overflow-y:scroll;height:250px;overflow-x:scroll;width:200px;">
                          <asp:CheckBoxList ID="List_dept" runat="server" Height="16px" Width="130px" AutoPostBack="True" 
                              OnSelectedIndexChanged="List_dept_SelectedIndexChanged"></asp:CheckBoxList>
                              </div></td></tr></table> <br />
                          
                        <label for="mtrAddress">场地地址 : </label>
                          <asp:DropDownList ID="mtrAddress" runat="server" DataSourceID="SqlDataSource4" DataTextField="addressName" DataValueField="addressName" AutoPostBack="True">
                            </asp:DropDownList>
                          <asp:TextBox ID="mtrAddress1" runat="server" Width="109px"></asp:TextBox>
             <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:meetingroomManagementConnectionString %>" SelectCommand="SELECT distinct addressName ,id FROM [VenueBooking].[dbo].[MTR_bas_AddressName] where [available] = '1' order by id"></asp:SqlDataSource>
            <br/>
                        <label for="mtrCap">容量 : </label>
                        <asp:TextBox ID="mtrCap" runat="server" Width="100px" onkeyup="if(isNaN(value))execCommand('undo')">
                        </asp:TextBox>
                        <br />

                          <label for="mtrCap">电话 : </label>
                        <asp:TextBox ID="mtrPhone" runat="server" Width="100px"></asp:TextBox>
                        <br />
                           <label for="mtrType"> 类型：</label>
                        <asp:DropDownList ID="mtrType" runat="server">
                            <asp:ListItem>VIP</asp:ListItem>
                            <asp:ListItem>普通</asp:ListItem>
                       </asp:DropDownList>
                          <br/>
                        <label for="mtrLongestBookingDay">最长预定</label>
                        <asp:TextBox ID="mtrLongestBookingDay" onkeyup="if(isNaN(value))execCommand('undo')" 
                             runat="server" style="margin-bottom: 0px" Width="50px"></asp:TextBox>
                        <label for="mtrLongestBookingDay">小时/次</label>
                            <br />
                         <label for="mtrLongestAdvanceBookingTime">最长提前</label>
                            <asp:TextBox ID="mtrLongestAdvanceBookingTime" onkeyup="if(isNaN(value))execCommand('undo')" 
                                runat="server" style="margin-bottom: 0px" Width="50px"></asp:TextBox>
                           <label for="mtrLongestAdvanceBookingTime">天预定</label><br/>
                          <label for="admin">管理员：</label>
                          <asp:DropDownList ID="admin" runat="server" Height="25px" Width="150px"></asp:DropDownList>
                          <br />
                          <br />
</fieldset>
                     
                      <div align="center">
                          <asp:Button ID="add" runat="server" OnClick="Button1_Click" Text="添加" />
                         <asp:Button ID="reset" runat="server" Text="重置" OnClick="reset_Click"/>
                      </div>
</div>
